#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
int main(int a,char *ar[])
{
    printf("process running...\n");
    pid_t id = fork();
    if(id==0)
    {
        sleep(1);
        execvp(ar[1],&ar[1]);
        /*char const *argv_[] = {
            "ls",
            "-a",
            "-l",
            NULL
        };
        char const *envp_[] ={
            (char*)"MYABC=123123123",
            NULL
        };
        //execl("/usr/bin/ls","ls","-a","-l",NULL);
        //execlp("ls","ls","-a","-l",NULL);
        //execv("/usr/bin/ls",argv_);
        //execvp("ls",argv_);
        //execl("./myexe","myexe",NULL);
        extern char **environ;
        putenv((char*)"MYABC=23423423423");//将指定的环境变量导入到系统中，environ指向的环境变量表
        execle("./myexe","myexe",NULL,environ);
        */


        exit(1);
        //child
        
    }
    int statuc  = 0;
    pid_t ret = waitpid(id,&statuc,0);
    if(ret>0)
        printf("wait success: exit code:%d ,sig:%d \n",(statuc>>8)&0xFF,statuc&0x7F);
    //printf("process sucess!\n");
    
    return 0;
}
